package com.ttx.springmvc.example.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author TimFruit
 * @date 19-7-28 下午6:02
 */
@Configuration
@EnableWebMvc
@EnableSwagger2
public class SwaggerConfig extends WebMvcConfigurerAdapter{

//    @Bean
//    public Docket swaggerSpringMvcPlugin() {
//        return new Docket(DocumentationType.SWAGGER_2)
////            .apiInfo(apiInfo())
//            .groupName("business-api")
//            .select()   // 选择那些路径和api会生成document
//            .apis(RequestHandlerSelectors.basePackage("com.ttx.springmvc.example"))
//            .paths(PathSelectors.any())
//            //.apis(RequestHandlerSelectors.any())  // 对所有api进行监控
//            //.paths(PathSelectors.any())   // 对所有路径进行监控
//            .build();
//    }

    @Override public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
        registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
    }
}
